import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

import { RemoveTableService } from 'app/public/serve/remove-table/remove-table.service';
import { HintsService } from 'app/public/serve/hints/hints.service';
import { Service } from '../../../server/server';
import { sysconfigUrl } from '../sysconfig.url';

@Component({
  selector: 'sysconfig-delete',
  templateUrl: './sysconfig-delete.component.html',
  styleUrls: ['./sysconfig-delete.component.css']
})
export class SysconfigDeleteComponent implements OnInit {

  @Output() delete = new EventEmitter<void>();

  constructor(
    private request: RemoveTableService,
    private hintsService: HintsService,
    public server: Service,
  ) {}

  ngOnInit() {
  }

  /**
   * 删除
   */
  _delete() {  

    this.request
        .confirmRemove('sysConfigId', this.server.baseUrl +sysconfigUrl.delete)
        .then((res: any)=>{
          if (res.result_code == '0000') {
            this.delete.emit();
          }
          this.hintsService.messages(res.message, res.result_code);
          return
        })
        .catch((err: any)=> {
          this.hintsService.messages('error', 'error');
          return
        })
  }

}
